package com.ruoyi.merchant.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.merchant.annotation.DictFilter;
import com.ruoyi.merchant.domain.ReminderSettings;
import com.ruoyi.merchant.service.IReminderSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 设备提醒设置Controller
 * 
 * @author ruoyi
 * @date 2024-09-03
 */
@Controller
@RequestMapping("/settings")
public class ReminderSettingsController extends BaseController
{
    @Autowired
    private IReminderSettingsService reminderSettingsService;

    /**
     * 查询设备提醒设置列表
     */
    @GetMapping("/list")
    @DictFilter(dataType = "page")
    @ResponseBody
    public TableDataInfo list(ReminderSettings reminderSettings)
    {
        startPage();
        List<ReminderSettings> list = reminderSettingsService.selectReminderSettingsList(reminderSettings);
        return getDataTable(list);
    }

    /**
     * 新增保存设备提醒设置
     */
    @Log(title = "设备提醒设置", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ReminderSettings reminderSettings)
    {
        return toAjax(reminderSettingsService.insertReminderSettings(reminderSettings));
    }

    /**
     * 修改保存设备提醒设置
     */
    @Log(title = "设备提醒设置", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ReminderSettings reminderSettings)
    {
        return toAjax(reminderSettingsService.updateReminderSettings(reminderSettings));
    }

    /**
     * 删除设备提醒设置
     */
    @Log(title = "设备提醒设置", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(reminderSettingsService.deleteReminderSettingsByIds(ids));
    }
}
